package com.beta.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.beta.em.admins.AdminRolesType;
import org.springframework.stereotype.Service;

import com.beta.mapper.AdminRolesMapper;
import com.beta.entity.AdminRoles;
import com.beta.service.IAdminRolesService;
import com.baomidou.framework.service.impl.SuperServiceImpl;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 *
 * AdminRoles 表数据服务层接口实现类
 *
 */
@Service
public class AdminRolesService extends SuperServiceImpl<AdminRolesMapper, AdminRoles> implements IAdminRolesService {


    @Override
    public List<AdminRoles> getAdminRolesById(Integer adminId) {
        if (Objects.isNull(adminId)) {
            return Collections.emptyList();
        }

        return baseMapper.selectRolesByAdminId(adminId);
    }

    @Override
    public List<AdminRoles> getAdminRoles() {
        List<AdminRoles> adminRoles = selectList(new EntityWrapper<>());
        for (AdminRoles role:adminRoles) {
            role.setName(AdminRolesType.getCnValue(role.getName()));
        }
        return adminRoles;
    }
}